#include <iostream>

using namespace std;
int Arr[2000001];
int main()
{
    int n, m, temp;

    scanf("%d %d",&n,&m);

    for (int i = 1; i <= n; i++) {
        scanf("%d",&Arr[i]);
    }

    for (int i = 0; i < m; i++)
    {
        scanf("%d",&temp);
        printf("%d\n",Arr[temp]);
    }

    return 0;
}
